<?php
/**
 * Created by 绵阳市碳素云信息技术有限责任公司.
 * User: castle
 * Date: 2015/05/15
 * Time: 10:29
 */

namespace Repair\Controller;

use Repair\Model\LogModel;
use Repair\Model\OrderModel;
use Think\Controller;

class LogController extends Controller{
    function __construct(){
        parent::__construct();
    }
    function add($Type,$Content,$OrderID){
        $LogModel = new LogModel();
        $OrderModel = new OrderModel();
        $LogModel->startTrans();
        $data['UID'] = UID.','.session('UN');
        $data['Type']=$Type;
        $data['Content']=$Content;
        $data['OrderID']=$OrderID;
        $rs[] = $LogModel->add($data);
        $rs[] = $OrderModel->where(array('OrderID'=>$OrderID))->save(array('Status'=>$Type));
        foreach($rs as $v){
            if(false===$v){
                $LogModel->rollback();
                $this->E('Error');
            }
        }
        $LogModel->commit();
    }
}